package no.ntnu.fp.gui.notice;
import java.awt.Dimension;

import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import no.ntnu.fp.model.Notice;

@SuppressWarnings("serial")
public class NoticeScrollPanel extends JPanel {
	private JScrollPane scroll;
	private JPanel mainPanel;
	
	public NoticeScrollPanel(){
		mainPanel = new JPanel();
		mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
		scroll = new JScrollPane(mainPanel);
		//scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		scroll.setPreferredSize(new Dimension(250, 350));
		this.add(scroll);
	}
	
	public void addNotice(Notice notice){
		mainPanel.add(new NoticePanel(notice), 0);
		scroll.validate();
	}
	public void clearPanel(){
		mainPanel.removeAll();
		scroll.validate();
	}
}
